﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StateTheater.Interfaces;
using Castle.MonoRail.Framework;
using Castle.MonoRail.Framework.Helpers;

namespace StateTheater.Component
{
    class MenuItemComponent : ViewComponent
    {
        private ICollection elements;
        private string style;
        private string action;
        private string controller;
        private string text;

        public override void Initialize()
        {
            style = ComponentParams["style"] as string;
            action = ComponentParams["action"] as string;
            controller = ComponentParams["controller"] as string;
            if (controller == null)
                controller = this.RailsContext.UrlInfo.Controller;

            text = ComponentParams["text"] as string;
            base.Initialize();
        }

        public override void Render()
        {
            RenderText(String.Format(@"<span class=""{0}"">", style));
            string applicationPath = base.Controller.Context.ApplicationPath;
            string extension = base.Controller.Context.UrlInfo.Extension;
            RenderText(string.Format("<a href=\"{0}/{1}/{2}.{3}\">{4}</a>", applicationPath, controller, action, extension, text ));
            RenderText("</span>");
        }

 

 

            base.Render();
        }
    }
}
